//Added by Tyler on May 6th

#pragma once

#include "Textures.h"
#include "Base Object.h"

#include <d3d9.h>
#pragma comment(lib, "d3d9.lib")
#include <d3dx9.h>
#pragma comment(lib, "d3dx9.lib")
#include <dxerr.h>
#pragma comment(lib, "dxerr.lib")

class Graphics
{
private:
	Graphics(){};
	//All Needed variables to run graphics
	IDirect3D9*             m_pD3D;
	IDirect3DDevice9*		m_pD3DDevice;
	ID3DXFont*              m_pFont;
	IDirect3DTexture9*	    m_pTexture;
	HWND					m_hWnd;
	RECT					m_rClientRect;
	D3DPRESENT_PARAMETERS	m_D3DParams;
	D3DSURFACE_DESC         m_texDesc;
	D3DXVECTOR3             m_vtexCenter;
	TextureList             m_TxList;


	//All variables that are needed to run "For Now"
	// Can be deleted modified and added to later

	/**			**\
		Light
	\**			**/
	D3DLIGHT9				m_Light;

	/**			**\
		Camera
	\**			**/
	D3DXMATRIX				m_matView;
	D3DXMATRIX				m_matPerspective;

	/**					**\
		Object Placement
	\**					**/
	D3DXMATRIX				m_matScale;
	D3DXMATRIX				m_matWorld;
	D3DXMATRIX              m_matTrans;                    
	D3DXMATRIX              m_matRotation;

	/**					**\
		Sprite Device
	\**					**/
	ID3DXSprite*			m_pSpriteDevice;

	/**		  **\
		Font
	\**		  **/
	//Can add more arrays if needed
	char m_aString[256];

	struct TextInfo
	{
		string m_String;
		RECT m_rect;
		bool ifDraw;
	};
	

	FunctionReturn InitDevice();
	FunctionReturn InitTextures();
public:
	~Graphics(){};
	inline static Graphics* Engine()
	{static Graphics G;return & G;}

	FunctionReturn Initialize(HWND);
	//Draw later to take argument of all items that want to draw
	FunctionReturn Draw(const DrawList*);
	FunctionReturn Render2DObjects(const DrawList*);
	FunctionReturn RenderFont();
	FunctionReturn RenderDebugTools();
	TextureInfo* GetTexbyIndex(int index){return m_TxList.get(index);}
	void CheckDevice();
	const inline RECT GetClientRect() const {return m_rClientRect;}


	TextInfo m_textarray[7];

	
};